//
//  JsSecretButton.m
//  productLine
//
//  Created by GikkiAres on 2019/3/19.
//  Copyright © 2019 base. All rights reserved.
//

#import "JsSecretButton.h"

@interface JsSecretButton()

{
	UITapGestureRecognizer * mTap_secret;
}

@end

@implementation JsSecretButton

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if(self = [super initWithCoder:aDecoder]) {
        [self commonInit];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if(self = [super initWithFrame:frame]) {
        [self commonInit];
    }
    return self;
}

- (instancetype)init {
    if(self = [super init]) {
        [self commonInit];
    }
    return self;
}

- (void)commonInit {
    UITapGestureRecognizer * tapOne = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onNormalTap:)];
    tapOne.numberOfTapsRequired = 1;
    [self addGestureRecognizer:tapOne];
  
	
    mTap_secret = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onSecretTap:)];
	mTap_secret.numberOfTapsRequired = 9;
    [self addGestureRecognizer:mTap_secret];
    
    [tapOne requireGestureRecognizerToFail:mTap_secret];
    
}

- (void)setSecretTapCount:(int)count {
	mTap_secret.numberOfTapsRequired = count;
}

- (void)onNormalTap:(UITapGestureRecognizer *)tap {
//    self.tapCount = 1;
	if(self.normalClickCallback) {
		self.normalClickCallback();
	}
    if(_delegate&&[_delegate respondsToSelector:@selector(jsSecretButtonNormalTap:)]) {
        [_delegate jsSecretButtonNormalTap:self];
    }
//    self.tapCount = 0;
}

- (void)onSecretTap:(UITapGestureRecognizer *)tap {
	if(self.secretClickCallback) {
		self.secretClickCallback();
	}
    if(_delegate&&[_delegate respondsToSelector:@selector(jsSecretButtonSecretTap:)]) {
        [_delegate jsSecretButtonSecretTap:self];
    }
}

@end
